package com.xingzuo.library_user.ui;

import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.ogaclejapan.smarttablayout.SmartTabLayout;
import com.xingzuo.base.app.AppActivityKey;
import com.xingzuo.base.ui.mvp.base.ui.BaseActivity;
import com.xingzuo.common.adapter.MyTitleViewPagerAdapter;
import com.xingzuo.library_user.R;
import com.xingzuo.library_user.R2;
import com.xingzuo.library_user.ui.fragment.CaseListFragment;
import com.xingzuo.library_user.ui.fragment.UnscrambleFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = AppActivityKey.UNSCRAMBLEACTIVITY)
public class UnscrambleActivity extends BaseActivity {
    @BindView(R2.id.iv_back)
    ImageView ivBack;
    @BindView(R2.id.sl_report)
    SmartTabLayout slReport;
    @BindView(R2.id.vp_content)
    ViewPager vpContent;
    private List<Fragment> fragments = new ArrayList<>();
    private List<String> titleList = new ArrayList<>();
    private MyTitleViewPagerAdapter myTitleViewPagerAdapter;
    @Override
    public int getView() {
        return R.layout.activity_unscramble;
    }

    @Override
    public void initView() {
        myTitleViewPagerAdapter = new MyTitleViewPagerAdapter(getSupportFragmentManager(), fragments, titleList);
        vpContent.setAdapter(myTitleViewPagerAdapter);
        vpContent.setOffscreenPageLimit(3);
        slReport.setViewPager(vpContent);
        vpContent.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                Log.e("insert", position + "==onPageScrolled==");
            }

            @Override
            public void onPageSelected(int position) {
                Log.e("insert", position + "==onPageSelected==");
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {
        fragments.add(new UnscrambleFragment(0));
        fragments.add(new UnscrambleFragment(1));
        titleList.add("最新");
        titleList.add("常规");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R2.id.iv_back)
    public void onViewClicked() {
        finish();
    }
}